package cn.zxf.note.security;

import cn.zxf.note.security.dto.BindDto;
import cn.zxf.note.security.dto.RegisterDto;
import cn.zxf.note.security.dto.ResetPasswordDto;
import cn.zxf.note.security.platform.LoginResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by zengxf on 2019/4/9.
 */
@Slf4j
@RestController
public class SecurityController {

    @Autowired
    private SecurityService service;


    @PostMapping("/api/security/login")
    public Map<String, Object> login(
            @RequestBody Map<String, String> map
    ) {
        return service.login(map);
    }

    @PostMapping("/api/security/platformLogin")
    public LoginResult platformLogin(
            @RequestBody Map<String, String> map
    ) {
        return service.platformLogin(map);
    }

    @PostMapping("/api/security/bind")
    public Map<String, String> bind(
            @RequestBody BindDto dto
    ) {
        return service.bind(dto);
    }

    @PostMapping("/api/security/register")
    public Map<String, String> register(
            @RequestBody RegisterDto dto
    ) {
        return service.register(dto);
    }

    @PostMapping("/api/security/resetPassword")
    public void resetPassword(
            @RequestBody ResetPasswordDto dto
    ) {
        service.resetPassword(dto);
    }

}
